<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>

<script language="javascript" src="{$ui_site}js/jquery.min.js" type="text/javascript" /></script>
<script language="javascript" src="{$ui_site}js/jquery.validate.js" type="text/javascript" /></script>
<script language="javascript" src="{$ui_site}js/jquery.metadata.js" type="text/javascript"></script>
{literal}
<style type="text/css">
<!--
body {
	margin-left: 3px;
	margin-top: 0px;
	margin-right: 3px;
	margin-bottom: 0px;
}
.STYLE1 {
	color: #e1e2e3;
	font-size: 12px;
}
.STYLE1 A{
color: white;
}
.STYLE6 {color: #000000; font-size: 12; }
.STYLE10 {color: #000000; font-size: 12px; }
.STYLE19 {
	color: #344b50;
	font-size: 12px;
}
.STYLE21 {
	font-size: 12px;
	color: #3b6375;
}
.STYLE22 {
	font-size: 12px;
	color: #295568;
}
.error{
	color: red;
}

p.info {
    clear: both;
    color: #999999;
    font-size: 11px;
    line-height: 20px;
    margin: 0 0 0 198px;
}
font{
cursor:pointer;
}
-->
</style>
<script language="javascript">
jQuery.extend(jQuery.validator.messages, {     required: "请填写本字段",     remote: "验证失败",     email: "请输入正确的电子邮件",     url: "请输入正确的网址",     date: "请输入正确的日期",     dateISO: "请输入正确的日期 (ISO).",     number: "请输入正确的数字",     digits: "请输入正确的整数",     creditcard: "请输入正确的信用卡号",    equalTo: "请再次输入相同的值",     accept: "请输入指定的后缀名的字符串",     maxlength: jQuery.validator.format("允许的最大长度为 {0} 个字符"),     minlength: jQuery.validator.format("允许的最小长度为 {0} 个字符"),     rangelength: jQuery.validator.format("限{0}-{1}位英文字母、数字、中文或其组合"),     range: jQuery.validator.format("请输入介于 {0} 和 {1} 之间的值"),     max: jQuery.validator.format("请输入一个最大为 {0} 的值"),     min: jQuery.validator.format("请输入一个最小为 {0} 的值") });
jQuery.validator.addMethod("isMobile", function(value, element){
    var length = value.length;
    return this.optional(element) || length == 11 && /^1[358]\d{9}$/.test(value);
}, "请填写正确的手机号码");

$(function(){
	$('#form').validate();
});
</script>

{/literal}
</head>

<body><b><font color="{$alert.color}">{$alert.str}</font></b>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="24" bgcolor="#353c44"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="6%" height="19" valign="bottom"><div align="center"><img src="{$ui_site}images/tb.gif" width="14" height="14" /></div></td>
                <td width="94%" valign="bottom"><span class="STYLE1"> 路书</span></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
  <td>
			<form id="form" action="{url('roadbook/add')}" method="POST">
				{literal}
				<b>名称：</b><input type="text" value="" name="data[roadbook_name]" class="text tipped required {rangelength:[2 ,20]}"><br>
				<b>简介：</b><br><textarea cols="50" rows="8" name="data[introduction]" class="text tipped"></textarea><br>
		
		
				<b>出发地(途径地ID)：</b><input type="text" onblur="isWay('depart')" value="" name="data[departname]" class="text tipped required">
				 <p class="info" id="showdepart">输入途径地名称！</p>
				<br>
				<input type="hidden" name="data[depart]" class="required number required" />
				
				<b>目的地(途径地ID)：</b><input type="text" onblur="isWay('destination')" value="" name="data[destinationname]" class="text tipped required">
				 <p class="info" id="showdestination">输入途径地名称！</p>
				 <br>
				<input type="hidden" name="data[destination]" class="required number required" />
		
				<b>路书行程：</b><input type="text" value="" name="data[journey]" >
				<b>路书里程：</b><input type="text" value="" name="data[kilometers]" class="text tipped required number"><br>
				<b>小贴士：</b><input type="text" value="" name="data[suggestions]" class=""><br>
				<b>路书标签：</b><input type="text" value="" name="data[marks]" class="text tipped required {rangelength:[2 ,20]}"><br>
				<b>作者：</b><input type="text" value="" name="data[author_name]" class="text tipped required {rangelength:[2 ,10]}"><br>
				{/literal}
				<br><input type="submit" value=" 确定 " name="ok">
			</form>
		</td>
  </tr>
  
  
</table>
</body>
</html>
<script language="javascript">

function isWay(name){
var wayname = $("input[name='data["+name+"name]']").val()  ;
if(wayname){
	$.get('{url("ajax/getWayByWname")}'+'&way_name='+wayname,function(data){
		if(data){
			var array = eval('('+data+')');
			var showstr='';
			for(var i=0;i<array.length;i++){
			//showstr+=(i+1)+':途径地名称：'+array[i]['name']+"<br>"+'途径地坐标：'+array[i]['latitude']+'<>'+array[i]['longitude']+'<br>';
			showstr+=(i+1)+':<font class='+name+' value='+array[i]['way_id']+'>'+array[i]['name']+'</font><br>';
			}
		}else{
			 $("input[name='data["+name+"name]']").val('')  ;
			var showstr='<font class=error>不存在的途径地条件:'+wayname+'！</font>';
		}
		$('#show'+name).html(showstr);
		bindclick(name);
		return false;
	});
}


$("input[name='"+name+"name']").focus();
}

function bindclick(name){
 $('.'+name).bind("click",function(){
 var word = $(this).html();
  var wid = $(this).attr('value');
 if(!isNaN(wid) && wid){
 $("input[name='data["+name+"]']").val(wid)  ;
  $("input[name='data["+name+"name]']").val(word)  ;
 }else{
 alert('未知错误');
 }
 
 });
 }

</script>